export const commonFeedBackMixin = {
  data() {
    return {
      // 是否处理下拉框选项
      handleOption: [
        { id: 0, value: "是" },
        { id: 1, value: "否" },
      ],
      // 反馈类型下拉框选项
      feedbackOption: [
        { id: 1, value: "投诉" },
        { id: 2, value: "建议" },
        { id: 3, value: "表扬" },
      ],
      // 反馈时间
      feedbackTime: [],
      // query参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      // body参数
      body: {
        isHandled: null,
        phoneNumber: "",
        name: "",
        feedbackType: "",
        handler: "",
        startHandlingTime: "",
        endHandlingTime: "",
      },
    };
  },
  computed: {
    // 计算请求体，动态生成请求的body对象
    requestBody() {
      return Object.fromEntries(
        Object.entries(this.body).filter(
          ([_, value]) => value !== null && value !== ''
        )
      );
    },
  },
  methods: {
    // 修改反馈时间
    changeTime(val) {
      // 检查val是否为null或者是有效的数组
      if (Array.isArray(val) && val.length === 2) {
        this.body.startHandlingTime = val[0];
        this.body.endHandlingTime = val[1];
      } else {
        // 如果val为null，清空时间
        this.body.startHandlingTime = '';
        this.body.endHandlingTime = '';
      }
    },
  },
};
